<?php include $this->admin_tpl('meta');?>
<title>内容管理 - YzmCMS内容管理系统</title>
<link href="<?php echo STATIC_URL;?>plugin/editable/css/jquery-editable.css" rel="stylesheet"/>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 内容列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
  <div> 
    <form action="<?php echo U('search');?>" method="get" id="search">
	 <input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
	 <input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
	 <input type="hidden" value="search" name="a">
     <span class="select-box inline">
		<select name="modelid" class="select" onchange="change_model()">
			<?php 
				foreach($modelinfo as $val){
					$str = $val['modelid']==$modelid ? 'selected' : '';
					echo '<option value="'.$val['modelid'].'" '.$str.'>'.$val['name'].'</option>';
				}
			?>
		</select>
	</span>
	 <span class="select-box inline"><?php echo select_category('catid', $catid, '内容分类', 0, '', true, true, $modelid); ?></span>
     更新时间：<input type="text" class="input-text laydate-icon" style="width:110px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start'] != '') echo 'value="'.$_GET['start'].'"'; ?>>
     至 <input type="text" class="input-text laydate-icon" style="width:110px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d'); ?>">
     <span class="select-box inline">
		<select name="flag" class="select">
		<option value="0">内容属性</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='1'){echo 'selected';} ?> value="1">置顶[1]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='2'){echo 'selected';} ?> value="2">头条[2]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='3'){echo 'selected';} ?> value="3">特荐[3]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='4'){echo 'selected';} ?> value="4">推荐[4]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='5'){echo 'selected';} ?> value="5">热点[5]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='6'){echo 'selected';} ?> value="6">幻灯[6]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='7'){echo 'selected';} ?> value="7">跳转[7]</option>
		</select>
	</span>
     <span class="select-box inline">
		<select name="status" class="select">
        <option value="99">状态</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='0'){echo 'selected';} ?> value="0">草稿</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='1'){echo 'selected';} ?> value="1">正常</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="type" class="select">
	    <option <?php if(isset($_GET["type"]) && $_GET["type"]=='1'){echo 'selected';} ?> value="1">内容标题</option>
		<option <?php if(isset($_GET["type"]) && $_GET["type"]=='2'){echo 'selected';} ?> value="2">发布人</option>	
		</select>
	</span>
     <input type="text" name="searinfo" class="input-text search" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success" type="submit" value="1"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	 </form>	
  </div>
  <div class="cl pd-5 bg-1 bk-gray mt-20"> 
  <span class="l">
  <a href="javascript:;" onclick="yzm_open_full('添加内容','<?php echo U('add', array('modelid'=>$modelid));?>')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加内容</a>
  <a href="javascript:;" onclick="yzm_dels('ids')" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
  <a href="javascript:;" onclick="baidu_push()" class="btn btn-secondary radius">推送至百度</a> 
  <a href="javascript:;" onclick="attribute_operation('移动分类', '<?php echo U('remove', array('modelid' => $modelid))?>')" class="btn btn-primary radius">移动分类</a> 
  <a href="javascript:;" onclick="attribute_operation('复制内容', '<?php echo U('copy', array('modelid' => $modelid))?>')" class="btn btn-primary radius">复制内容</a> 
  <a href="javascript:;" onclick="attribute_operation('增加属性', '<?php echo U('attribute_operation', array('modelid' => $modelid, 'op' => 1))?>')" class="btn btn-primary radius">增加属性</a> 
  <a href="javascript:;" onclick="attribute_operation('删除属性', '<?php echo U('attribute_operation', array('modelid' => $modelid, 'op' => 0))?>')" class="btn btn-primary radius">删除属性</a> 
  </span> <span class="r">共有数据：<strong><?php echo $total?></strong> 条</span> </div>
  <form method="post" action="<?php echo U('del');?>" id="myform">
  <input type="hidden" name="modelid" value="<?php echo $modelid;?>">
  <table class="table table-border table-bordered table-bg table-hover yzm-table-sort">
    <thead>
      <tr class="text-c">
        <th width="25"><input type="checkbox"></th>
		<th width="50">ID<?php echo field_order('id');?></th>
		<th>标题</th>
		<th width="120">内容分类<?php echo field_order('catid');?></th>
		<th width="65">点击量<?php echo field_order('click');?></th>
		<th width="120">发布人<?php echo field_order('username');?></th>
		<th width="135">更新时间<?php echo field_order('updatetime');?></th>
		<th width="50">状态<?php echo field_order('status');?></th>
		<th width="50">推送<?php echo field_order('is_push');?></th>
		<th width="55">管理操作</th>
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="checkbox" value="<?php echo $val['id']?>" name="ids[]"></td>
			<td><?php echo $val['id']?></td>
			<td class="text-l">
			<a href="<?php echo $val['url'];?>" target="_blank" ><?php echo title_color($val['title'], $val['color']);?></a>
			<?php
			if($val['thumb']){
			 echo '<span style="color:#0a6999;margin:0 3px" title="含缩略图"><i class="Hui-iconfont">&#xe646;</i></span>';
			}
			if(strpos($val['flag'], '1') !== false){
			 echo '<span class="c-red">[置顶]</span>';
			}
            if(strpos($val['flag'], '2') !== false){
			 echo '<span class="c-red">[头条]</span>';
			}
            if(strpos($val['flag'], '3') !== false){
			 echo '<span class="c-red">[特荐]</span>';
			}
            if(strpos($val['flag'], '4') !== false){
			 echo '<span class="c-red">[推荐]</span>';
			}
            if(strpos($val['flag'], '5') !== false){
			 echo '<span class="c-red">[热点]</span>';
			}
            if(strpos($val['flag'], '6') !== false){
			 echo '<span class="c-red">[幻灯]</span>';
			}
			if(strpos($val['flag'], '7') !== false){
			 echo '<span class="c-red">[跳转]</span>';
			}
			if($val['readpoint']){
			 echo '<span class="c-red">[付费]</span>';
			}			
			?>	
			</td>
			<td><?php echo get_catname($val['catid']);?></td>
			<td><span class="click" data-pk="<?php echo $val['id']?>"><?php echo $val['click']?></span></td>
			<td><?php echo $val['username'];if(!$val['system']) echo '<span style="color:blue;margin-left:3px;" title="会员发布"><i class="Hui-iconfont">&#xe60d;</i><span>';?></td>
			<td><?php echo date('Y-m-d H:i:s', $val['updatetime'])?></td>
			<td><?php echo $val['status'] ? '<span class="label label-success radius">正常</span>' : '<span class="label radius">草稿</span>';?></td>
			<td><?php echo $val['is_push'] ? '已推送' : '<span class="c-red">未推送</span>';?></td>
			<td>
				<a title="编辑" href="javascript:;" onclick="yzm_open_full('编辑内容','<?php echo U('edit',array('modelid'=>$modelid,'id'=>$val['id']));?>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
				<a title="预览" href="<?php echo $val['url'];?>" class="ml-5" target="_blank" style="text-decoration:none"><i class="Hui-iconfont">&#xe695;</i></a>
			</td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  </form>
  <div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/editable/js/jquery.poshytip.js"></script>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/editable/js/jquery-editable-poshytip.min.js"></script>
<script type="text/javascript">

	$('.click').editable({
	    url: '<?php echo U('public_fast_edit');?>',
	    name: 'click',
	    title: '数据修改',
	    params: {"modelid":"<?php echo $modelid?>"},
	    dataType: "json", 
	    validate:function (value) {
	        if(value=='' || isNaN(value) || value < 0){
	            return '点击量必须为数字且不能小于0！';
	        }
	    },
	    success: function(msg, newvalue) {
	        if(!msg.status){
	        	return msg.message; 
		    }
	    }
	});

	function attribute_operation(s, url){
		var ids = $("input[name='ids[]']:checked");
		if (ids.length<1){
		   layer.alert('请勾选信息！');
		   return false;
		}

		var str = '';
		$.each(ids,function(){
			if(this.checked){
				str += $(this).val() + ',';
			}
		 });
		str = str.substr(0,str.length-1);
		layer.open({  
	        type: 2,  
	        title: s,  
	        shadeClose: true,  
	        shade: 0.2,  
	        area: ['500px', '250px'],  
	        content: url,
			success: function(layero, index){
				var body = layer.getChildFrame('body', index);
				body.find('#ids').val(str);
			}
		})  
					
	}

	function baidu_push() {
		var ids = $("input[name='ids[]']:checked");
		if (ids.length<1){
		   layer.alert('请勾选信息！');
		   return false;
		}

		document.getElementById('myform').action='<?php echo U('baidu_push');?>';
		document.getElementById('myform').submit();
	}

	function change_model(){
		$("#search").submit();
	}

	var start = {
		elem: '#start',
		format: 'YYYY-MM-DD',
		min: '1999-01-01', //设定最小日期
		max: '2099-01-01', //最大日期
		istime: false,
		istoday: false,
		choose: function(datas){
			 end.min = datas; //开始日选好后，重置结束日的最小日期
			 end.start = datas //将结束日的初始值设定为开始日
		}
	};

	var end = {
		elem: '#end',
		format: 'YYYY-MM-DD',
		min: '1999-01-01',
		max: '2099-01-01',
		istime: false,
		istoday: false,
		choose: function(datas){
			start.max = datas; //结束日选好后，充值开始日的最大日期
		}
	};
	laydate(start);
	laydate(end);
</script>

</body>
</html>